import React, { Component } from 'react'
import PropTypes from 'prop-types'
import { Modal } from 'antd-mobile';
import * as utils from '../../../utils'
import Numbers from '../../../components/Numbers'
export default class GiftItem extends Component {
  static propTypes={
    onClickLeft_gift:PropTypes.func,
  };
  constructor(props){
    super(props)
    
  }

 
  componentDidMount(){
    

  }
  onClickLeft_gift(id,type,e){
   if(this.props.onClickLeft_gift instanceof Function){
     this.props.onClickLeft_gift(id,type,e)
   }
  }
  
  

  render(){
    let { gitem,type } =this.props
    console.log(gitem)
    return (
    <div className='gitem'>
    <img className='limg' 
      onClick={ this.onClickLeft_gift.bind(this,gitem.goods_id,type)} 
      src={gitem.goods_image} style={{width:'60px',height:'60px'}}
    />
    <div className='rinfo'>
      <p className='line-clamp-2 name'>{gitem.goods_name}</p>
      <p className='line-clamp-1 spec'>{gitem.spec_str}</p>
      {
        type ==2?<p className='red'>${gitem.goods_price}</p>:<p className='red'>free gift</p>
      }
      {
        type == 2?
       <div className='num-btn-plane'> <Numbers minNum={0} value={+gitem.goods_num} onCallBack={(num)=>{
                  this.props.changeGiftGoodsNum(gitem,num)
                 }} /></div>
                 :
        null
      }
      
    </div>
  </div>
  )
  }
 
 
} 



















